<template>
  <div class="cate_container">
    <div class="title">
      <h3> 商店【 <font color="#FF0000">{{shopName}}</font>】商品目录 </h3>
    </div>
    
    <div class="select">
      <div class="cate">
        <div class="all" @click="toggle">
          <img src="@/assets/images/base.gif" alt />
          <span>所有类别</span>
        </div>
        <div class="cate-list">
          <TreeItem class="item" v-for="item in trees" :item="item" :key="item.id" />
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import TreeItem  from '@/components/TreeItem';
export default {
  components: {
    TreeItem
  },
  data() {
    return {
      shopName: "xxxshop",
      expandAll:false,
      trees: [
        {
          id: 1,
          label: "连环画",
          count: 98,
          test: 1,
          children: [
            {
              id: "1-1",
              label: "二级目录",
              count: 30,
              test: 2
            },
            {
              id: "1-2",
              label: "二级目录",
              count: 25,
              test: 2
            },
            {
              id: "1-3",
              label: "二级目录",
              count: 10,
              test: 2
            }
          ]
        },
        {
          id: 2,
          label: "书籍报刊",
          count: 98,
          test: 1
        },
        {
          id: 3,
          label: "文学书籍",
          count: 33,
          test: 1,
          children: [
            {
              id: "3-1",
              label: "二级目录",
              count: 25,
              test: 2
            },
            {
              id: "3-2",
              label: "二级目录",
              count: 36,
              test: 2,
              children: [
                {
                  id: "3-2-1",
                  label: "三级目录",
                  count: 16,
                  test: 3,
                  flag: 3
                },
                {
                  id: "3-2-2",
                  label: "三级目录",
                  count: 98,
                  test: 3,
                  flag: 3
                },
                {
                  id: "3-2-3",
                  label: "三级目录",
                  count: 98,
                  test: 3,
                  flag: 3
                },
                {
                  id: "3-2-4",
                  label: "三级目录",
                  count: 16,
                  test: 3,
                  flag: 3
                },
                {
                  id: "3-2-5",
                  label: "三级目录",
                  count: 98,
                  test: 3,
                  flag: 3
                },
                {
                  id: "3-2-6",
                  label: "三级目录",
                  count: 98,
                  test: 3,
                  flag: 3
                }
              ]
            }
          ]
        }
      ]
    };
  },
  methods: {
    toggle() {
      let {expandAll} = this;
      this.expandAll = !expandAll;
      this.eventBus.$emit('setexpand', !expandAll);
    },
    getShopName(data) {
      this.shopName = data;
    }
  }
};
</script>
<style lang="scss">
.cate_container {
  width: 100%;
  // border-top: 6px solid #5191ce;
  // border-bottom: 6px solid #5191ce;
  // line-height: 40px;
  a {
    font-size: 24px;
    color: #ff0000;
    font-weight: bold;
    margin: 0 5px 0 10px;
  }
  span:nth-child(3) {
    color: #ff00ff;
    margin: 0 5px;
  }
  span:nth-of-type(3) {
    color: #b3b2b2;
    font-size: 16px;
    margin-right: 5px;
  }
  img {
    width: 20px;
    height: 20px;
    transform: translateY(5px);
  }
}
.title {
  width: 100%;
  height: 51px;
  line-height: 51px;
  background-color: #edf5fc;
}
.cate {
  .all {
    padding:5px 0;
  }
}
.cate-list{
  width:150px;
  .item {
    >ul{
      margin-left:1em;
    }
  }
}

</style>
